import { useRoutes,Navigate } from 'react-router-dom'
import Home from '../views/Home'
import Music from '../views/Music'
import News from '../views/News'
import Hots from '../views/Hots'
import ErrorPage from '../views/ErrorPage'
import Detail from '../views/Detail'
const RouterView = () => {
    const routes = useRoutes(
        [
            {
                path: '/',
                element: <Home />
            },
            {
                path: '/music',
                element: <Music />,
                children:[
                    //路由重定向
                    {
                      path:"/music",
                      element:<Navigate to="/music/news"/>
                    },
                    {
                        path:"news",
                        element:<News/>
                    },
                    {
                        path:"hots",
                        element:<Hots/>
                    },
                ]
            },
            {
                path: '*',
                element:<ErrorPage/> 
            },
            {
                path: '/detail/:id',
                element:<Detail/> 
            },
        ])
    return routes
}
export default RouterView